# -*- coding: utf-8 -*-

from game import GameBoard
from constant import SWIPE_LEFT, SWIPE_UP, SWIPE_DOWN, SWIPE_RIGHT

if __name__ == '__main__':
    print('inited')
    board = GameBoard()
    print(board)

    print('set [1,1]=2')
    board.set_value(1, 1, 2)
    print(board)
    print('move left')
    board.move(SWIPE_LEFT)
    print(board)
    print('set [1,2]=4')
    board.set_value(1, 2, 4)
    print(board)
    print('move left')
    board.move(SWIPE_LEFT)
    print(board)

    print('clear')
    board.clear()
    print(board)
    print('set [1,1]=2')
    board.set_value(1, 1, 2)
    print(board)
    print('move right')
    board.move(SWIPE_RIGHT)
    print(board)
    print('set [1,2]=2')
    board.set_value(1, 2, 2)
    print(board)
    print('move right')
    board.move(SWIPE_RIGHT)
    print(board)

    board.clear()
    board.set_value(0, 0, 2)
    board.set_value(0, 1, 2)
    board.set_value(0, 2, 4)
    board.set_value(0, 3, 8)
    print(board)
    merge_count = board.merges_in_row(0)
    print(merge_count)

    board.clear()
    board.set_value(0, 0, 2)
    board.set_value(0, 1, 4)
    board.set_value(0, 2, 4)
    board.set_value(0, 3, 0)
    print(board)
    merge_count = board.merges_in_row(0)
    print(merge_count)

    board.clear()
    board.set_value(0, 0, 2)
    board.set_value(0, 1, 0)
    board.set_value(0, 2, 2)
    board.set_value(0, 3, 2)
    print(board)
    merge_count = board.merges_in_row(0)
    print(merge_count)

    board.clear()
    board.set_value(0, 0, 2)
    board.set_value(0, 1, 4)
    board.set_value(0, 2, 2)
    board.set_value(0, 3, 2)
    print(board)
    merge_count = board.merges_in_row(0)
    print(merge_count)

    board.clear()
    board.set_value(0, 0, 8)
    board.set_value(0, 1, 4)
    board.set_value(0, 2, 2)
    board.set_value(0, 3, 2)
    print(board)
    merge_count = board.merges_in_row(0)
    print(merge_count)

    board.clear()
    board.set_value(0, 0, 8)
    board.set_value(0, 1, 0)
    board.set_value(0, 2, 2)
    board.set_value(0, 3, 0)
    print(board)
    merge_count = board.merges_in_row(0)

    board.clear()
    board.set_value(0, 0, 2)
    board.set_value(0, 1, 2)
    board.set_value(0, 2, 2)
    board.set_value(0, 3, 2)
    board.move(SWIPE_LEFT)

    board.clear()
    board.set_value(0, 0, 2)
    board.set_value(0, 1, 2)
    board.set_value(0, 2, 2)
    board.set_value(0, 3, 2)
    board.move(SWIPE_RIGHT)

    board.clear()
    board.set_value(0, 0, 2)
    board.set_value(0, 1, 0)
    board.set_value(0, 2, 2)
    board.set_value(0, 3, 2)
    board.move(SWIPE_RIGHT)
    board.clear()
    board.set_value(0, 0, 2)
    board.set_value(0, 1, 2)
    board.set_value(0, 2, 0)
    board.set_value(0, 3, 2)
    board.move(SWIPE_RIGHT)

    board.clear()
    board.set_value(0, 0, 2)
    board.set_value(0, 1, 0)
    board.set_value(0, 2, 0)
    board.set_value(0, 3, 2)
    board.move(SWIPE_RIGHT)

    board.clear()
    board.set_value(0, 0, 2)
    board.set_value(0, 1, 2)
    board.set_value(0, 2, 4)
    board.set_value(0, 3, 2)
    board.move(SWIPE_RIGHT)
    board.move(SWIPE_LEFT)

    board.clear()
    board.set_value(0, 0, 2)
    board.set_value(1, 0, 2)
    board.set_value(2, 0, 4)
    board.set_value(3, 0, 2)
    board.move(SWIPE_UP)

    board.clear()
    board.set_value(0, 0, 2)
    board.set_value(1, 0, 2)
    board.set_value(2, 0, 2)
    board.set_value(3, 0, 2)
    board.move(SWIPE_UP)

    board.clear()
    board.set_value(0, 0, 2)
    board.set_value(1, 0, 2)
    board.set_value(2, 0, 0)
    board.set_value(3, 0, 2)
    board.move(SWIPE_UP)

    board.clear()
    board.set_value(0, 0, 2)
    board.set_value(1, 0, 0)
    board.set_value(2, 0, 0)
    board.set_value(3, 0, 2)
    board.move(SWIPE_UP)

    board.clear()
    board.set_value(0, 0, 2)
    board.set_value(1, 0, 2)
    board.set_value(2, 0, 4)
    board.set_value(3, 0, 2)
    board.move(SWIPE_DOWN)

    board.clear()
    board.set_value(0, 0, 2)
    board.set_value(1, 0, 2)
    board.set_value(2, 0, 2)
    board.set_value(3, 0, 2)
    board.move(SWIPE_DOWN)

    board.clear()
    board.set_value(0, 0, 2)
    board.set_value(1, 0, 2)
    board.set_value(2, 0, 0)
    board.set_value(3, 0, 2)
    board.move(SWIPE_DOWN)

    board.clear()
    board.set_value(0, 0, 2)
    board.set_value(1, 0, 0)
    board.set_value(2, 0, 0)
    board.set_value(3, 0, 2)
    board.move(SWIPE_DOWN)
    new_board = board.copy_new()
    board.move(SWIPE_DOWN)
    print(new_board.equals(board))